<?php
$first = true;
foreach ($menu_items as $item) {
	if ($item->is_first_level) {
		if (!$first) {
			echo '</ul>';
			echo '</li>';
		}
		?>
		<li class="first-level-item <?php if (!$item->online) echo 'offline'?>" id="menuitem_<?= $item->id ?>">			
			<span class="right-box">
				<a href="javascript:menu_add_item(<?= $menu->id ?>, <?= $item->id ?>)" class="link">
					<?= icon_tag('add') ?> Ajouter un sous-élément
				</a>
			</span>
			<span class="icon-box">
				<?= delete_link($item, 'menu_delete_item') ?>
			</span>
			<a href="javascript:menu_edit_item(<?= $item->id ?>)" class="link">
				<?= $item->name ?> <?= icon_tag('pencil') ?>
			</a>
		<?php
		$first = false;
		echo '<ul class="second-level">';
	}
	else { ?>
		<li class="second-level-item <?php if (!$item->online) echo 'offline'?>" id="menuitem_<?= $item->id ?>">
			<span class="icon-box">
				<span class="handle"><?= icon_tag('handle') ?></span>
				<?= delete_link($item, 'menu_delete_item') ?>
			</span>
			<a href="javascript:menu_edit_item(<?= $item->id ?>)" class="link">
				<?= $item->name ?> <?= icon_tag('pencil') ?>
			</a>
		</li>
		<?php
	}
	
} ?>
	</ul>
</li>
